package com.wonders.frame.autoGeneration.support.enums;

import com.wonders.frame.common.Constant;

/**
 * @author 顾乘瑞
 */
public enum JsxElementEnum {
    INPUT(
            "                                <Form.Item {...Constants.FORM_ITEM_LAYOUT_MODAL}" +
                    " label=\"" + Constant.ELEMENT_PLACEHOLDER1 + "\">\n" +
                    "                                    {getFieldDecorator('" + Constant.ELEMENT_PLACEHOLDER2 + "', {\n" +
                    "                                        rules: [{required: true, message: '请输入" + Constant.ELEMENT_PLACEHOLDER1 + "'}],\n" +
                    "                                    })(\n" +
                    "                                        <Input placeholder=\"请输入" + Constant.ELEMENT_PLACEHOLDER1 + "\"/>\n" +
                    "                                    )}\n" +
                    "                                </Form.Item>\n",
            "                <Col span={10} offset={1}>\n" +
                    "                    <Form.Item {...Constants.FORM_ITEM_LAYOUT_SEARCH} " +
                    "label={'" + Constant.ELEMENT_PLACEHOLDER1 + "'}>\n" +
                    "                        {getFieldDecorator('" + Constant.ELEMENT_PLACEHOLDER2 + "_like', {\n" +
                    "                        })(\n" +
                    "                            <Input placeholder=\"请输入" + Constant.ELEMENT_PLACEHOLDER1 + "\"/>\n" +
                    "                        )}\n" +
                    "                    </Form.Item>\n" +
                    "                </Col>\n",
            "",
            "",
            ""
    ),
    DATE(
            "                                <Form.Item {...Constants.FORM_ITEM_LAYOUT_MODAL} label=\"" + Constant.ELEMENT_PLACEHOLDER1 + "\">\n" +
                    "                                    {getFieldDecorator('" + Constant.ELEMENT_PLACEHOLDER2 + "', {\n" +
                    "                                        rules: [{required: true, message: '请选择" + Constant.ELEMENT_PLACEHOLDER1 + "'}],\n" +
                    "                                    })(\n" +
                    "                                        <DatePicker format={Constants.DATE_FORMAT}  style={{minWidth: \"100%\"}}/>\n" +
                    "                                    )}\n" +
                    "                                </Form.Item>\n",
            "                <Col span={6} offset={1}>\n" +
                    "                    <Form.Item {...Constants.FORM_ITEM_LAYOUT_SEARCH_DATE} label={'" + Constant.ELEMENT_PLACEHOLDER1 + "'}>\n" +
                    "                        {getFieldDecorator('" + Constant.ELEMENT_PLACEHOLDER2 + "_gtFormatDate', {\n" +
                    "                        })(\n" +
                    "                            <DatePicker  style={{minWidth: \"100%\"}}/>\n" +
                    "                        )}\n" +
                    "                    </Form.Item>\n" +
                    "                </Col>\n" +
                    "                <Col span={1} style={{textAlign: \"center\",height:40,lineHeight:\"40px\"}}>~</Col>\n" +
                    "                <Col span={3}>\n" +
                    "                    <Form.Item {...Constants.FORM_ITEM_LAYOUT_DATE}>\n" +
                    "                        {getFieldDecorator('" + Constant.ELEMENT_PLACEHOLDER2 + "_ltFormatDate', {\n" +
                    "                        })(\n" +
                    "                            <DatePicker  style={{minWidth: \"100%\"}}/>\n" +
                    "                        )}\n" +
                    "                    </Form.Item>\n" +
                    "                </Col>\n",
            "            if(values['" + Constant.ELEMENT_PLACEHOLDER2 + "_gtFormatDate']){\n" +
                    "                values['" + Constant.ELEMENT_PLACEHOLDER2 + "_gtFormatDate'] = values['" + Constant.ELEMENT_PLACEHOLDER2 + "_gtFormatDate'].format(Constants.DATE_FORMAT)\n" +
                    "            }\n" +
                    "            if(values['" + Constant.ELEMENT_PLACEHOLDER2 + "_ltFormatDate']){\n" +
                    "                values['" + Constant.ELEMENT_PLACEHOLDER2 + "_ltFormatDate'] = values['" + Constant.ELEMENT_PLACEHOLDER2 + "_ltFormatDate'].format(Constants.DATE_FORMAT)\n" +
                    "            }\n",

            "                " + Constant.ELEMENT_PLACEHOLDER2 + ": values['" + Constant.ELEMENT_PLACEHOLDER2 + "'].format(Constants.DATE_FORMAT),\n",
            "            " + Constant.ELEMENT_PLACEHOLDER2 + ": moment(record." + Constant.ELEMENT_PLACEHOLDER2 + "),\n"
    ),
    DATETIME(
            "                                <Form.Item {...Constants.FORM_ITEM_LAYOUT_MODAL} label=\"" + Constant.ELEMENT_PLACEHOLDER1 + "\">\n" +
                    "                                    {getFieldDecorator('" + Constant.ELEMENT_PLACEHOLDER2 + "', {\n" +
                    "                                        rules: [{required: true, message: '请选择" + Constant.ELEMENT_PLACEHOLDER1 + "'}],\n" +
                    "                                    })(\n" +
                    "                                        <DatePicker showTime format={Constants.DATE_TIME_FORMAT}  style={{minWidth: \"100%\"}}/>\n" +
                    "                                    )}\n" +
                    "                                </Form.Item>\n",
            "                <Col span={6} offset={1}>\n" +
                    "                    <Form.Item {...Constants.FORM_ITEM_LAYOUT_SEARCH_DATE} label={'" + Constant.ELEMENT_PLACEHOLDER1 + "'}>\n" +
                    "                        {getFieldDecorator('" + Constant.ELEMENT_PLACEHOLDER2 + "_gtFormatDateTime', {\n" +
                    "                        })(\n" +
                    "                            <DatePicker showTime  style={{minWidth: \"100%\"}}/>\n" +
                    "                        )}\n" +
                    "                    </Form.Item>\n" +
                    "                </Col>\n" +
                    "                <Col span={1} style={{textAlign: \"center\",height:40,lineHeight:\"40px\"}}>~</Col>\n" +
                    "                <Col span={3}>\n" +
                    "                    <Form.Item {...Constants.FORM_ITEM_LAYOUT_DATE}>\n" +
                    "                        {getFieldDecorator('" + Constant.ELEMENT_PLACEHOLDER2 + "_ltFormatDateTime', {\n" +
                    "                        })(\n" +
                    "                            <DatePicker showTime  style={{minWidth: \"100%\"}}/>\n" +
                    "                        )}\n" +
                    "                    </Form.Item>\n" +
                    "                </Col>\n",
            "            if(values['" + Constant.ELEMENT_PLACEHOLDER2 + "_gtFormatDateTime']){\n" +
                    "                values['" + Constant.ELEMENT_PLACEHOLDER2 + "_gtFormatDateTime'] = values['" + Constant.ELEMENT_PLACEHOLDER2 + "_gtFormatDateTime'].format(Constants.DATE_TIME_FORMAT)\n" +
                    "            }\n" +
                    "            if(values['" + Constant.ELEMENT_PLACEHOLDER2 + "_ltFormatDateTime']){\n" +
                    "                values['" + Constant.ELEMENT_PLACEHOLDER2 + "_ltFormatDateTime'] = values['" + Constant.ELEMENT_PLACEHOLDER2 + "_ltFormatDateTime'].format(Constants.DATE_TIME_FORMAT)\n" +
                    "            }\n",
            "                " + Constant.ELEMENT_PLACEHOLDER2 + ": values['" + Constant.ELEMENT_PLACEHOLDER2 + "'].format(Constants.DATE_TIME_FORMAT),\n",
            "            " + Constant.ELEMENT_PLACEHOLDER2 + ": moment(record." + Constant.ELEMENT_PLACEHOLDER2 + "),\n"
    ),
    INPUT_NUM(
            "                                <Form.Item {...Constants.FORM_ITEM_LAYOUT_MODAL}" +
                    " label=\"" + Constant.ELEMENT_PLACEHOLDER1 + "\">\n" +
                    "                                    {getFieldDecorator('" + Constant.ELEMENT_PLACEHOLDER2 + "', {\n" +
                    "                                        rules: [{required: true, message: '请输入" + Constant.ELEMENT_PLACEHOLDER1 + "'}],\n" +
                    "                                    })(\n" +
                    "                                        <InputNumber style={{width:'100%'}} placeholder=\"请输入" + Constant.ELEMENT_PLACEHOLDER1 + "\"/>\n" +
                    "                                    )}\n" +
                    "                                </Form.Item>\n",
            "                <Col span={10} offset={1}>\n" +
                    "                    <Form.Item {...Constants.FORM_ITEM_LAYOUT_SEARCH} " +
                    "label={'" + Constant.ELEMENT_PLACEHOLDER1 + "'}>\n" +
                    "                        {getFieldDecorator('" + Constant.ELEMENT_PLACEHOLDER2 + "_eq', {\n" +
                    "                        })(\n" +
                    "                            <InputNumber style={{width:'100%'}} placeholder=\"请输入" + Constant.ELEMENT_PLACEHOLDER1 + "\"/>\n" +
                    "                        )}\n" +
                    "                    </Form.Item>\n" +
                    "                </Col>\n",
            "",
            "",
            ""
    )
    ;
    private String addHtml;
    private String searchHtml;
    private String searchSpecialOperate;
    private String modifySpecialOperate;
    private String saveSpecialOperate;
    JsxElementEnum(String addHtml, String searchHtml, String searchSpecialOperate,
                   String saveSpecialOperate, String modifySpecialOperate){
        this.addHtml = addHtml;
        this.searchHtml = searchHtml;
        this.searchSpecialOperate = searchSpecialOperate;
        this.saveSpecialOperate = saveSpecialOperate;
        this.modifySpecialOperate = modifySpecialOperate;
    }

    public String getAddHtml(String p1, String p2){
        String html = this.addHtml
                .replaceAll(Constant.ELEMENT_PLACEHOLDER1, p1)
                .replaceAll(Constant.ELEMENT_PLACEHOLDER2, p2);
        return html;
    }
    public String getSearchHtml(String p1, String p2){
        String html = this.searchHtml.replaceAll(Constant.ELEMENT_PLACEHOLDER1, p1)
                .replaceAll(Constant.ELEMENT_PLACEHOLDER2, p2);
        return html;
    }

    public String getSearchSpecialOperate(String p2) {
        return searchSpecialOperate.replaceAll(Constant.ELEMENT_PLACEHOLDER2, p2);
    }
    public String getModifySpecialOperate(String p2) {
        return modifySpecialOperate.replaceAll(Constant.ELEMENT_PLACEHOLDER2, p2);
    }
    public String getSaveSpecialOperate(String p2) {
        return saveSpecialOperate.replaceAll(Constant.ELEMENT_PLACEHOLDER2, p2);
    }
}
